﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

using YLClient.YLServiceReference;

namespace YLClient.Froms
{
    public delegate void OnResultArriveEventHandler(WorkItem[] items);
    /// <summary>
    /// Interaction logic for Searcher.xaml
    /// </summary>
    public partial class Searcher : Window
    {
        public event OnResultArriveEventHandler OnResultArrive;
        UserServiceClient client;
        public Searcher()
        {
            InitializeComponent();
            client = GlobalClass.DataContainer.Client;
        }
        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            var start = timePickStart.Time;
            var end = timePickEnd.Time;
            try
            {
                var items = client.GetWorkItemsByDate(start, end, GlobalClass.DataContainer.Guid);
                if (OnResultArrive != null)
                {
                    OnResultArrive(items);
                }
                this.Close();
            }
            catch
            {
                MessageBox.Show("网络异常,查询失败！");
            }
        }
    }
}
